]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status: Add new airplane mode indicator / menu
authorJasper St. Pierre <jstpierre@mecheye.net>
Mon, 27 May 2013 21:54:50 +0000 (17:54 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Tue, 13 Aug 2013 10:50:25 +0000 (06:50 -0400)
This is a simple indicator that shows if the user is currently in
airplane mode, and if they are, offers a way to turn it off. It
will not be shown if the user is not in airplane mode.

This is a part of the new system status design, see
https://wiki.gnome.org/GnomeShell/Design/Guidelines/SystemStatus/
for design details.

https://bugzilla.gnome.org/show_bug.cgi?id=705845

js/Makefile.am
js/ui/panel.js
js/ui/status/rfkill.js [new file with mode: 0644]

index 5184bb2f666eb6124f9f2c6e99e97b8a66435a19..e750db1ff571cbb41bd5421805dc932c040c3883 100644 (file)
@@ -92,6 +92,7 @@ nobase_dist_js_DATA =         \
        ui/status/keyboard.js   \
        ui/status/network.js    \
        ui/status/power.js      \
+       ui/status/rfkill.js     \
        ui/status/volume.js     \
        ui/status/bluetooth.js  \
        ui/status/system.js     \
index 16e8b6ad91593e5f9ae06f3beab02b294e34c4d7..2eea063bb26811de066d34905a5764857d7f2324 100644 (file)
@@ -853,11 +853,13 @@ const AggregateMenu = new Lang.Class({
         this._network = new imports.ui.status.network.NMApplet();
         this._bluetooth = new imports.ui.status.bluetooth.Indicator();
         this._power = new imports.ui.status.power.Indicator();
+        this._rfkill = new imports.ui.status.rfkill.Indicator();
         this._volume = new imports.ui.status.volume.Indicator();
         this._system = new imports.ui.status.system.Indicator();
 
         this._indicators.add_child(this._network.indicators);
         this._indicators.add_child(this._bluetooth.indicators);
+        this._indicators.add_child(this._rfkill.indicators);
         this._indicators.add_child(this._volume.indicators);
         this._indicators.add_child(this._power.indicators);
         this._indicators.add_child(new St.Label({ text: '\u25BE',
@@ -868,6 +870,7 @@ const AggregateMenu = new Lang.Class({
         this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
         this.menu.addMenuItem(this._network.menu);
         this.menu.addMenuItem(this._bluetooth.menu);
+        this.menu.addMenuItem(this._rfkill.menu);
         this.menu.addMenuItem(this._power.menu);
         this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
         this.menu.addMenuItem(this._system.menu);
diff --git a/js/ui/status/rfkill.js b/js/ui/status/rfkill.js
new file mode 100644 (file)
index 0000000..9628f2d
--- /dev/null
@@ -0,0 +1,58 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+
+const Gio = imports.gi.Gio;
+const Lang = imports.lang;
+
+const PanelMenu = imports.ui.panelMenu;
+const PopupMenu = imports.ui.popupMenu;
+
+const BUS_NAME = 'org.gnome.SettingsDaemon.Rfkill';
+const OBJECT_PATH = '/org/gnome/SettingsDaemon/Rfkill';
+
+const RfkillManagerInterface = <interface name="org.gnome.SettingsDaemon.Rfkill">
+<property name="AirplaneMode" type="b" access="readwrite" />
+</interface>;
+
+const RfkillManagerProxy = Gio.DBusProxy.makeProxyWrapper(RfkillManagerInterface);
+
+const Indicator = new Lang.Class({
+    Name: 'RfkillIndicator',
+    Extends: PanelMenu.SystemIndicator,
+
+    _init: function() {
+        this.parent();
+
+        this._proxy = new RfkillManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH,
+                                             Lang.bind(this, function(proxy, error) {
+                                                 if (error) {
+                                                     log(error.message);
+                                                     return;
+                                                 }
+                                                 this._proxy.connect('g-properties-changed',
+                                                                     Lang.bind(this, this._sync));
+                                                 this._sync();
+                                             }));
+
+        this._indicator = this._addIndicator();
+        this._indicator.icon_name = 'airplane-mode-symbolic';
+        this._indicator.hide();
+
+        // The menu only appears when airplane mode is on, so just
+        // statically build it as if it was on, rather than dynamically
+        // changing the menu contents.
+        this._item = new PopupMenu.PopupSubMenuMenuItem(_("Airplane Mode"), true);
+        this._item.icon.icon_name = 'airplane-mode-symbolic';
+        this._item.status.text = _("On");
+        this._item.menu.addAction(_("Turn Off"), Lang.bind(this, function() {
+            this._proxy.AirplaneMode = false;
+        }));
+        this._item.menu.addSettingsAction(_("Network Settings"), 'gnome-network-panel.desktop');
+        this.menu.addMenuItem(this._item);
+    },
+
+    _sync: function() {
+        let airplaneMode = this._proxy.AirplaneMode;
+        this._indicator.visible = airplaneMode;
+        this._item.actor.visible = airplaneMode;
+    },
+});